/**
 * Created by IntelliJ IDEA.
 * User: alexander
 * Date: 19.09.11
 * Time: 12:14
 * To change this template use File | Settings | File Templates.
 */
package com.towerdefence.towers {
import com.etc.towers.BlueTower1;
import com.etc.towers.GreenTower1;
import com.etc.towers.RedTower1;
import com.etc.towers.Tower_mc;

public class TowerFactory {

	private static var TOWERS: Object = {
		'tower-a' : { clazz: GunTower, animation: RedTower1, radius: 60, damage: 0.7, interval: 10, bspeed: 200, cost: 100, levelup:null },
		'tower-b' : { clazz: GunTower, animation: BlueTower1, radius: 90, damage: 0.3, interval: 10, bspeed: 800, cost: 100, levelup:null },
		'tower-c' : { clazz: GunTower, animation: GreenTower1, radius: 30, damage: 0.9, interval: 4, bspeed: 500, cost: 100, levelup:null }
	};

	public static function newTower( name: String ): GunTower {
		var p: Object = TOWERS[name];
		var cls: Class = p.clazz;
		var inst: GunTower = ( new cls() ) as GunTower;

		// setting props
		inst.towerName = name;
		inst.sprite = ( new (p.animation)()) as Tower_mc;
		inst.attackRadius = p.radius;
		inst.attackDamage = p.damage;
		inst.attackInterval = p.interval;
		inst.bulletSpeed = p.bspeed;

		return inst;
	}

}
}
